﻿using Benefactor.Models.DbModels;
using Bigway.Common.Services.Repositories;
using SqlSugar;

namespace Benefactor.Services.Repositories;

public class IssuedBenefitsCardRepository(IServiceProvider sp) :
    BaseSqliteEntityRepository<IssuedBenefitsCard>(sp),
    IIssuedBenefitsCardRepository
{
    public async Task<List<string>> GetDistinctIdsAsync(
        Func<ISugarQueryable<IssuedBenefitsCard>, ISugarQueryable<IssuedBenefitsCard>> filter, 
        CancellationToken token = default)
    {
        var query = filter(Queryable);
        var issuedBenefitsCardIdQuery = query
            .Select(x => x.Id)
            .Distinct();
        return await issuedBenefitsCardIdQuery.ToListAsync(token);
    }
}